package cn.edu.zafu.bigdata.override;
// 定义书籍类Book
public class Book {
    // 定义字段
    private String title;
    private String author;
    private double price;

    // 带参构造器
    public Book(String title, String author, double price) {
        this.title = title;
        this.author = author;
        this.price = price;
    }

    // 获取title
    public String getTitle() {
        return title;
    }

    // 设置title
    public void setTitle(String title) {
        this.title = title;
    }

    // 获取author
    public String getAuthor() {
        return author;
    }

    // 设置author
    public void setAuthor(String author) {
        this.author = author;
    }

    // 获取price
    public double getPrice() {
        return price;
    }

    // 设置price
    public void setPrice(double price) {
        this.price = price;
    }

    // 重写toString()方法
    @Override
    public String toString() {
        return "Book[title=" + title + ", author=" + author + ", price=" + price + "]";
    }

    // 测试类
    public static void main(String[] args) {
        // 创建几个Book对象
        Book book1 = new Book("Java Programming", "John Doe", 29.99);
        Book book2 = new Book("Python Basics", "Jane Smith", 24.99);
        Book book3 = new Book("Data Science", "Alice Johnson", 39.99);

        // 打印书籍信息
        System.out.println(book1);
        System.out.println(book2);
        System.out.println(book3);
    }
}
